# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: William Grieshaber <me@zee.li>

pkgname=dnscrypt-wrapper
pkgver=0.4.2
pkgrel=3
pkgdesc="A server-side dnscrypt proxy"
url="https://dnscrypt.org/"
arch=('loong64' 'x86_64')
license=('BSD')
depends=('libsodium' 'libevent')
backup=('etc/default/dnscrypt-wrapper')
install=dnscrypt-wrapper.install
source=("$pkgname-$pkgver.tar.gz::https://github.com/cofyc/dnscrypt-wrapper/archive/v$pkgver.tar.gz"
        dnscrypt-wrapper.sysusers)
sha512sums=('f45afc6e0468c48ad9ded54cfd7d5314c68d49afda5faf3c7c3b6f8f41f77501565967ba6666f3723ba735c8d7f8d98a7777010a4fcf215b3d76707411243400'
            '91dfdf0be4eb0d1f8d29bbfadfef451e09a5eed4464afdb531b67354a1c9357224d46340e4472eb37aaa6c2ba2f1dc685ccaa24dfa7666dd2cb5ac8c0a55b7db')

prepare() {
  cd $pkgname-$pkgver
  sed -i 's|/usr/sbin|/usr/bin|' debian/dnscrypt-wrapper.service
}

build() {
  cd $pkgname-$pkgver
  make configure
  ./configure
  make
}

check(){
  cd $pkgname-$pkgver/tests
  # TODO
  # make test
}

package() {
  cd $pkgname-$pkgver
  make sbindir="$pkgdir"/usr/bin install

  install -Dm644 debian/dnscrypt-wrapper.service "$pkgdir"/usr/lib/systemd/system/dnscrypt-wrapper.service
  install -Dm644 debian/dnscrypt-wrapper.default "$pkgdir"/etc/default/dnscrypt-wrapper
  install -Dm644 "$srcdir"/dnscrypt-wrapper.sysusers "$pkgdir/usr/lib/sysusers.d/dnscrypt-wrapper.conf"

  install -Dm644 COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING
  install -Dm644 debian/dnscrypt-wrapper.8 "$pkgdir"/usr/share/man/man8/dnscrypt-wrapper.8
}

# vim:set ts=2 sw=2 et:
